<?php
/**
 * 活动控制器 WEB显示层
 */
namespace Feedback\Controller;

class WapController extends AppController {
	/**
	 * 意见箱
	 */
	public function index(){
		$message = D('Message');
		if (IS_POST) {
			$message = D('Message');
			$data = $message->create();
			if (!$data) {
				$this->error($message->getError());
			}else{
				$result = $message->add();
				if ($result) {
					$this->success('反馈成功，我们会尽快给您回复！',U('Feedback/Index/index'));
				}else{
					$this->error($message->getError());
				}
			}
		}else{
			$this->display();
		}
	}

	public function show(){
		$message = D('Message');
		$map = array();
		$map['reply'] = array('NEQ','');
		
		$count = $message->where($map)->count();
		$page = new \Com\Page($count,"15");
		$limit = $page->firstRow.','.$page->listRows;
		$field = "*";
		$order = "id desc";
		$list = $message->where($map)->field($field)->limit($limit)->order($order)->select();
		$data = array('list'=>$list,'page'=>$page->show());
		
		$this->assign($data);
		$this->display();
	}

	public function getInfo(){
		return array(
            array(
                'Title'       => '建议反馈',
                'Description'       => '建议反馈入口',
                'PicUrl'       => $this->site_url.'Public/Static/images/logo.png',
                'Url'       => $this->site_url.U('Feedback/Wechat/index',array('openid'=>$from)),
            )
        );
	}
}